package com.flower.tokenCenter.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.flower.tokenCenter.entity.ResultEntity;
import com.flower.tokenCenter.entity.TokenEntity;
import com.flower.tokenCenter.service.TokenService;


/**  

* <p>Title: TokenController</p>  

* <p>Description:token中控组件</p>  

* @author QingFeng  

* @date 2020年5月14日  

*/  
@RestController
@RequestMapping(value = "/v1/apis")
public class TokenController {
	
	@Autowired
	private TokenService tokenService;
	
	/**  
	
	 * <p>Title: getToken</p>  
	
	 * <p>Description:根据appid获取token 及创建日期 </p>  
	
	 * @param appId
	 * @param nonceStr
	 * @param sign
	 * @return  
	
	 */  
	@RequestMapping(value = "/getToken")
	public ResultEntity getToken(String appId,String nonceStr,String sign) {
		TokenEntity token =tokenService.getToken(appId,nonceStr,sign);
		return new ResultEntity("000001", token);
	}
	
	/**  
	
	 * <p>Title: refreshToken</p>  
	
	 * <p>Description: </p>  
	
	 * @param appId
	 * @param nonceStr
	 * @param sign
	 * @return  
	
	 */  
	@RequestMapping(value = "/refreshToken")
	public ResultEntity refreshToken(String appId,String nonceStr,String sign) {
		TokenEntity token = tokenService.refreshToken(appId,nonceStr,sign);
		return new ResultEntity("000001", token);
	}
	
	/**  
	
	 * <p>Title: deleteToken</p>  
	
	 * <p>Description: </p>  
	
	 * @param appId
	 * @param nonceStr
	 * @param sign
	 * @return  
	
	 */  
	@RequestMapping(value = "/deleteToken")
	public ResultEntity deleteToken(String appId,String nonceStr,String sign) {
		tokenService.deleteToken(appId,nonceStr,sign);
		return new ResultEntity("000001", "delete ok");
	}
}
